-
Notifications
You must be signed in to change notification settings - Fork 433
Manage Grafana Service Accounts from the Grafana CR #1907
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the PR! :D
As this is WIP I have mostly commented on style rather than functionality or wording.
Since you diligent with adding logs, I would like to direct you to: https://github.com/grafana/grafana-operator/blob/master/controllers/contactpoint_controller.go#L209
It's one of the few examples of debug level logs in the project by adding the .V(1)
It could be useful to you if you've been wanting to add more logs but have been holding back.
In case you have questions, feel free to leave comments!
44516fc
to
297df4d
Compare
fc35937
to
45a06ca
Compare
4d3109a
to
881b3c0
Compare
75871ab
to
f96b8a8
Compare
f62728d
to
c1fc015
Compare
7d582d5
to
bdbccc4
Compare
Thank you for your continued investment in this feature - it's very appreciated! We took some time to answer your questions
If it doesn't singificantly simplify the implementation, we'd prefer for service accounts to be specified as part of the Grafana CR.
When keeping the service accounts as part of the
This is a good point and being able to specify the namespace for the secret is something that we definetly want
This isn't really a questions but more of a topic for a follow-up PR. For what
We discussed this and came to the conclusion that conditions are probably the
The only situation in which a finalizer would be applicable would be with
This is something we can explore in a follow up PR. Let's keep it to the default Again thanks for all the work! If you have more questions or want to chat about this PR, feel free to join our maintainer meeting every Monday at 11:00 CEST. If you prefer async communication, discussing this further in the PR is also always possible :) |
conditions: - lastTransitionTime: "2025-05-14T21:57:17Z" message: Grafana reconcile completed observedGeneration: 3 reason: GrafanaReady status: "True" type: Ready
14c215f
to
f283415
Compare
#1469
See full de# proposal #003.
Summary
This PR introduces declarative management of Grafana Service Accounts (SAs) through the
Grafana
CR.The operator now provisions, updates, and cleans up SAs, their API tokens, and the corresponding Kubernetes
Secret
s, keeping them in sync with the desired state.Architecture highlights
GrafanaServiceAccountReconciler
watches the sameGrafana
objects asGrafanaReconciler
but is scoped to SA concerns only.GrafanaReady == True
; otherwise it requeues.status
sub‑resource to minimise write conflicts.status.serviceAccounts
list to avoid accidentally taking ownership of user‑managed SAs/tokens.What's implemented
spec.grafanaServiceAccounts
field on theGrafana
CR.Secret
s.tests/e2e/grafanaserviceaccount/chainsaw-test.yaml
.TODO
Secret
s into a custom namespace.expires
attribute.feat_grafana_conditions
branch (condition‑based flow) and rebase this PR.GrafanaReconciler
once conditions are in place to avoid dual‑reconciler status clashes.Known limitations / caveats
Status single source of truth - Reconciliation logic treats
status.serviceAccounts
as the single ownership ledger.status
. On the next run it sees the SA missing fromstatus
, issues a new create call, receives a 409 already exists error, and halts.Dual‑reconciler vs single‑reconciler design - Keeping
GrafanaServiceAccountReconciler
separate isolates SA logic and shortens unit‑test feedback loops, but it also:An alternative is to invoke SA reconciliation inside
GrafanaReconciler
after the stage loop, gated byGrafanaReady
. This would avoid write conflicts at the cost of a fatter reconciler and slightly later SA provisioning.Default organisation only - All API calls target the default Grafana org; multi‑org support is out of scope for this PR.
Same‑namespace Secrets - Until cross‑namespace write support is added, token
Secret
s are created in the Grafana namespace.Previous Discussion Summary
Grafana
CR. A standalone CRD would complicate matching one SA to multiple instances and secret handling.Grafana
.Secret
to a user‑specified namespace; to be added.Conditions
. I'll rebase on that once it lands.orgId
support - Restrict to the default organisation for this PR and revisit later.